package com.archie.xunji.huodong.adapters;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.archie.xunji.R;
import com.archie.xunji.huodong.entity.HotAndNewData;

import java.util.List;

/**
 * Created
 * Author:bi[FR]
 * Date:15-11-11
 */
public class ListView_HuodongAdapter extends BaseAdapter {

    private Context context;
    private List<HotAndNewData>datas;

    public ListView_HuodongAdapter(Context contex,List<HotAndNewData>datas){
        this.context=contex;
        this.datas=datas;
    }

    @Override
    public int getCount() {
        int ret=0;
        if(datas!=null)
            ret=datas.size();
        return ret;
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder=null;
        if(convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.item_listview_huodong,parent,false);
            holder=new ViewHolder();
            holder.tv_name= (TextView) convertView.findViewById(R.id.tv_name_item_listView_huodong);
            holder.tv_pv= (TextView) convertView.findViewById(R.id.tv_pv_item_listView_huodong);
            holder.linear= (LinearLayout) convertView.findViewById(R.id.linear_huodongadapter);

            convertView.setTag(holder);
        }else holder= (ViewHolder) convertView.getTag();

        holder.tv_name.setText("#"+datas.get(position).getName()+"#");
        holder.tv_pv.setText(datas.get(position).getPv()+"");
        if(position%2==1)
            holder.linear.setBackgroundColor(Color.parseColor("#dddddd"));
        else
            holder.linear.setBackgroundColor(Color.parseColor("#eeeeee"));

        return convertView;
    }


    private static class ViewHolder{
        TextView tv_name,tv_pv;
        LinearLayout linear;
    }


}
